package com.zz.config;

import com.zz.pojo.Apple;
import com.zz.pojo.User;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@Configuration
public class UserConfig {
//    @Bean
//    public Apple apple(){
//        Apple apple = new Apple();
//        return apple;
//    }

    @Bean
    //原生注解
    //@Conditional(UserCondition.class)

    //派生注解
    //@ConditionalOnClass(Apple.class)

    //@ConditionalOnBean(Apple.class)

    //@ConditionalOnMissingBean(Apple.class)

    @ConditionalOnProperty(name = "person",havingValue = "zhangsan")
    public User user(){
        User user = new User("张三", "男", 30);
        return user;
    }


}
